function Skip(selector){
	this.ele = $(selector).get(0);
	$(this.ele).find('li').on({
			'click':function(){
				this.index=$(this).index();
				if(this.index==7){
					window.open("insidepages.html")
				}
			}
	})
}
function Jumppages(selector){
	this.ele = $(selector).get(0);
	$(this.ele).find('li').on({
		'click':function(){
			this.index=$(this).index();
			if(this.index==0){
				window.open("landingpage.html");
			}else if(this.index==1){
				window.open("registerpage.html");
			}else if(this.index==3){
				window.open("shopcat.html");
			}	
		}
	})
	
}
//轮播图
function Carousel(selector) {
	this.ele = $(selector).get(0);
	this.index=1;
	this.btnAction();
	this.Mouseevent();
	this.buttonAction()
	this.timer=setInterval(this.moveAction.bind(this),3000);
}
Carousel.prototype.btnAction = function() {//左右按钮

	var onself = this;
	
	$(onself.ele).find('.btn').click(function() {
		
		this.id=='left' ? --onself.index : ++onself.index;
		onself.change();
	})
}
Carousel.prototype.Mouseevent = function(){
		var onself = this;
		$(onself.ele).on({
			'mouseenter': function() {
				clearInterval(onself.timer);
				$('.btn').toggle();
			},
			'mouseleave': function() {
				onself.timer=setInterval(onself.moveAction.bind(onself),3000);
				$('.btn').toggle();
			},
		})
			
}
Carousel.prototype.moveAction = function() {   //自动轮播
		var onself = this;
		onself.index++;
		onself.change();
}
Carousel.prototype.buttonAction = function() {
		var onself = this;	
		$(onself.ele).find('.button li').click(function() {
			onself.index=$(this).index()+1;
			onself.change();
		})
}
	
Carousel.prototype.change=function(){
	var onself = this;
	var length = $(onself.ele).find('.list').children('li').size();
	if(onself.index <= 0) {
				$(onself.ele).find('.list').css('left', -$(onself.ele).find('.list li').width() * (length-1))
				onself.index =4;

	}else if(onself.index>length-2) {
				onself.index = 1;
				$(onself.ele).find('.list').css('left', 0)
	}
	$(onself.ele).find('.list').stop().animate({
				'left':-$(onself.ele).find('.list li').width() * onself.index
			}, 400)
	$(onself.ele).find('.button li').eq(onself.index - 1).addClass('select').siblings().removeClass();
}

//小轮播
function Newbroadcast(selector) {
	this.title = $(selector).get(0);
	this.ele=$('.new_list').get(0);
	this.index=1;
	this.buttonAction()
}
Newbroadcast.prototype.buttonAction = function() {
		var onself = this;	
		$('.smallbroadcast').find('span').click(function() {
			onself.index=$(this).index();
			$(onself.ele).stop().animate({
				'left':-$(onself.ele).find('ul').width() * onself.index
			}, 400);
	$('.smallbroadcast').find('span').eq(onself.index).addClass('smallselect').siblings().removeClass();
		})
}
	
//楼梯效果
function Scrolltop(selector){
	this.ele = $(selector).get(0);
	this.up=$('.showup').get(0);
   console.log(4);
	this.mouseaction();
	
}
Scrolltop.prototype.mouseaction=function(){
	onself=this;
	var length = $(onself.up).find('li').size();
	$(onself.up).find(' li').on({
		'mouseenter mouseleave ': function() {
				
				this.index=$(this).index();
				if(this.index==1){
					$('.show').toggle();
				}
			
			},
		
		'click':function(){
			
			onself=this;
			console.log(onself.index)			
			 if(onself.index>1 && onself.index<length-1){
					$(window).scrollTop((onself.index+1)*($(window).height()+130));
				}
				else if(onself.index==length-1){
					$(window).scrollTop(0)
				}

		}
})
	$(window).scroll(function(){

		
		if($('html body').scrollTop()>200) {
				$(onself.ele).css('display','block');
				$(onself.ele).css('left',$(window).width()-60);
				
			}else{
				$(onself.ele).css('display','none')
			}
							
						
					
	})
}

function Settime(selector){
	this.ele = $(selector).get(0);
	this.gettimeto();
	setInterval(this.gettimeto,1000)
}
Settime.prototype.gettimeto=function(){
	 var EndTime= new Date('2017/06/18 00:00:00');   /*结束时间*/
    var NowTime = new Date(); 

    var t =EndTime.getTime() - NowTime.getTime();

    var d=0;
   
    if(t>=0){
      d=Math.floor(t/1000/60/60/24);
    }
    $(this.ele).find('i').html(d);
}
